home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 21.zip / BS1 part 21 / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].7z / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].adf / rexx.lzh / SavePrefs.pprx < prev    next >
Text File  |  1992-03-13  |  7KB  |  258 lines

  1. /*
  2. @BSavePrefs  @P@ICopyright Gold Disk Inc., January, 1992
  3.  
  4. This Genie will save any settings in the current PPage environment to a config file. Professional Page will then always start up with your specified settings. (Example: Magnification, Colormode, Interlace, etc...) 
  5.  
  6. */
  7. address command
  8. call SafeEndEdit.rexx()
  9.  
  10. cr  = '0a'x
  11. startclip   = "/*****Start Clips*****/"
  12. endclip     = "/*****End Clips*****/"
  13. startprefs  = "/*****Start Prefs*****/"
  14. endprefs    = "/*****End Prefs*****/"
  15. startsave   = "/*****StartSave*****/"
  16. endsave     = "/*****EndSave*******/"
  17. startupfile = "s:ppage.config"
  18. styletagdef    = "s:styletags.dflt"
  19. paratagdef    = "s:paratags.dflt"
  20. startup     = ''
  21. clist       = 0
  22.  
  23. selection   = "AngleStep"
  24. selection   = selection || cr"BaseLine"
  25. selection   = selection || cr"BoxOutlines"
  26. selection   = selection || cr"ColorMode"
  27. selection   = selection || cr"Columns"
  28. selection   = selection || cr"DateFormat"
  29. selection   = selection || cr"DitherMode"
  30. selection   = selection || cr"FillColor"
  31. selection   = selection || cr"FillPattern"
  32. selection   = selection || cr"Font"
  33. selection   = selection || cr"Grid"
  34. selection   = selection || cr"GridSize"
  35. selection   = selection || cr"GridSnap"
  36. selection   = selection || cr"Hyphenation"
  37. selection   = selection || cr"HyphenControl"
  38. selection   = selection || cr"HyphenLang"
  39. selection   = selection || cr"Interlace"
  40. selection   = selection || cr"Interrupt"
  41. selection   = selection || cr"Justification"
  42. selection   = selection || cr"Kerning"
  43. selection   = selection || cr"LineColor"
  44. selection   = selection || cr"LinePattern"
  45. selection   = selection || cr"LineSpacing"
  46. selection   = selection || cr"LineWeight"
  47. selection   = selection || cr"MagMode"
  48. selection   = selection || cr"PageNumFormat"
  49. selection   = selection || cr"ParaTag"
  50. selection   = selection || cr"QuickMove"
  51. selection   = selection || cr"RulerType"
  52. selection   = selection || cr"Size"
  53. selection   = selection || cr"Style"
  54. selection   = selection || cr"StyleTag"
  55. selection   = selection || cr"TextColor"
  56. selection   = selection || cr"TextGreek"
  57. selection   = selection || cr"TextFilter"
  58. selection   = selection || cr"Tracking"
  59. selection   = selection || cr"Units"
  60. selection   = selection || cr"WireFrame"
  61. selection   = selection || cr"Workbench"
  62.  
  63. counter = 1
  64.  
  65. special = "TEXTCOLOR TEXTFILTER FONT LINECOLOR FILLCOLOR PARATAG STYLETAG"
  66.  
  67. /*  if exists then read file into line array and separate sections  */
  68. if ~exists(startupfile) then
  69. do
  70.     startup = "/*"cr || '09'x || "Professional Page Configuration File"cr"*/"
  71.  
  72.     entry   = "In order to facilitate automated address entry using Page Genies, Professional Pages stores personal information in a configuration file. Would you like to fill out the info form?"
  73.  
  74.     if ppm_Inform(2, entry,"No","Yes") then
  75.     do
  76.  
  77.         form    = "Name"cr"Company Name"cr"Address"cr"City"cr"State/Province"cr"Country"cr"Zip/Postal Code"cr"Phone"cr"Fax"
  78.  
  79.         form    = ppm_GetForm("Information Form", 35, form)
  80.         if form = '' then exit_msg()
  81.  
  82.         parse var form name '0a'x comp '0a'x add '0a'x city '0a'x state '0a'x country '0a'x zc '0a'x phone '0a'x fax
  83.  
  84.         prefix  = "call setclip(ppuser_"
  85.  
  86.         clips.1 = startclip
  87.         clips.2 = prefix || 'name,"'name'")'
  88.         clips.3 = prefix || 'company,"'comp'")'
  89.         clips.4 = prefix || 'address,"'add'")'
  90.         clips.5 = prefix || 'phone,"'phone'")'
  91.         clips.6 = prefix || 'zipcode,"'zc'")'
  92.         clips.7 = prefix || 'city,"'city'")'
  93.         clips.8 = prefix || 'state,"'state'")'
  94.         clips.9 = prefix || 'country,"'country'")'
  95.         clips.10 = prefix || 'fax,"'fax'")'
  96.         clips.11= endclip
  97.         clist   = 11
  98.  
  99.     end
  100.  
  101. end
  102. else
  103. do
  104.  
  105.     if ~open(file, startupfile, "r") then
  106.         call exit_msg("DOS error. Unable to create a configuration file.")
  107.  
  108.     do while ~eof(file)
  109.  
  110.         text = strip(readln(file))
  111.         if text = '' then iterate
  112.  
  113.         if text = startprefs then
  114.         do while ~eof(file)
  115.  
  116.             text = readln(file)
  117.             if text = endprefs then leave
  118.  
  119.         end
  120.         else if text = startsave then
  121.         do while ~eof(file)
  122.  
  123.             text = readln(file)
  124.             if text = endsave then leave
  125.  
  126.         end
  127.         else
  128.             startup = startup || cr || text
  129.  
  130.     end
  131.  
  132.     call close(file)
  133.  
  134. end
  135.  
  136. if exists(startupfile) then
  137. do
  138.     address command
  139.     'copy' startupfile startupfile".bak"
  140.     address
  141. end
  142.  
  143. selection   = ppm_SelectFromList("Select Settings to Save", 20, 9, 1, selection)
  144. if selection = '' then exit_msg()
  145.  
  146. /*    execute instructions at the end of list first >> SETUNITS    */
  147. selection = ppm_SortList(selection, 1, 0)
  148.  
  149. call ppm_ShowStatus("Working")
  150.  
  151. startup = startup || cr || startprefs || cr"call ppm_AutoUpdate(0)"cr
  152.  
  153. if pos('StyleTag', selection) ~= 0 then
  154. do
  155.     call ppm_SetBatchMode(1)
  156.     call ppm_SaveStyleTags(styletagdef) 
  157.  
  158.     startup = startup || cr || "call ppm_SetBatchMode(1)"
  159.     startup = startup || cr || "call ppm_LoadStyleTags('"styletagdef"')"
  160.     startup = startup || cr || "call ppm_SetBatchMode(0)"
  161.     call ppm_SetBatchMode(0)
  162.  
  163. end
  164.  
  165. if pos('ParaTag', selection) ~= 0 then
  166. do
  167.     call ppm_SetBatchMode(1)
  168.     call ppm_SaveParaTags(paratagdef) 
  169.  
  170.     startup = startup || cr || "call ppm_SetBatchMode(1)"
  171.     startup = startup || cr || "call ppm_LoadParaTags('"paratagdef"')"
  172.     startup = startup || cr || "call ppm_SetBatchMode(0)"
  173.     call ppm_SetBatchMode(0)
  174.  
  175. end
  176.  
  177. do while selection ~= ''
  178.  
  179.     parse var selection command '0a'x selection
  180.     command = strip(command)
  181.  
  182.     if command = '' then iterate
  183.  
  184.     interpret "setting = ppm_Get"command"()"
  185.  
  186.     if words(setting) > 1 & pos(upper(command), special) = 0 then
  187.         setting = separate(setting)
  188.     else if ~datatype(setting,n) then setting = '"'setting'"'
  189.  
  190.     command = "call ppm_Set"command"("setting")"
  191.  
  192.     startup = startup || cr || command
  193.  
  194. end
  195.  
  196. if ppm_Inform(2, "Would you like to save the default page?", "No", "Yes") then
  197. do
  198.     startup = startup || cr
  199.     startup = startup ||"call ppm_SetPageType(default,"||ppm_GetPageType(default)")"cr
  200.     startup = startup ||"call ppm_SetPageSize(default,"||separate(ppm_GetPageSize(default))")"cr
  201.     startup = startup ||"call ppm_SetPageMargins(default,"||separate(ppm_GetPageMargins(default))")"cr
  202.     startup = startup ||"call ppm_SetPageColumns(default,"||separate(ppm_GetPageColumns(default))")"cr
  203. end
  204.  
  205. startup = startup || cr"call ppm_AutoUpdate(1)"cr ||  endprefs
  206.  
  207. if ppm_Inform(2, "Would you like to have the AutoSave Genie run upon startup?", "No", "Yes") then
  208.     startup  = startup || cr||startsave||cr"address command"cr"'rx' 'rexx:AutoSave.pprx'"cr||endsave
  209.  
  210. if ~open(file, startupfile, "w") then exit_msg("Unable to open config file")
  211. call writeln(file, startup)
  212.  
  213. do i = 1 to clist
  214.     call writeln(file, clips.i)
  215. end
  216.  
  217. call close(file)
  218.  
  219. call ppm_ShowStatus("Done")
  220.  
  221. exit_msg()
  222.  
  223. separate:
  224. do
  225.     arg settings
  226.  
  227.     inpar   = ''
  228.  
  229.     do i = 1 to (words(settings) - 1)
  230.  
  231.         set     = word(settings, 1)
  232.  
  233.         inpar   = inpar||set","
  234.         settings    = subword(settings,2)
  235.  
  236.     end
  237.  
  238.     inpar = inpar||settings
  239.  
  240.     return(inpar)
  241.  
  242. end
  243.  
  244.  
  245. exit_msg:
  246. do
  247.  
  248.     arg message
  249.  
  250.     if message ~= '' then
  251.         call ppm_Inform(1, message,)
  252.  
  253.     call ppm_ClearStatus()
  254.     call ppm_AutoUpdate(1)
  255.     exit
  256.  
  257. end
  258.